import express from 'express';
import https from 'https';
import cors from 'cors';
import { router } from './routes/routes';
import { globalConfig } from '../config';

// 获取Express应用实例
const _app = express();

// 设置跨域
_app.use(
  cors({
    origin: [globalConfig.httpServerUrl],
    credentials: true // 允许发送带凭据的请求
  })
);

_app.use(express.json());

// 配置主路由
_app.use('/api', router);

export const app = _app;

export const createHttpsServer = https.createServer;
